---
title: Discovery
index: 25
---

# Discovery

Discovery is the process of finding other nodes to connect with.

We do this through the following 3 systems:

- Manual entry by the user
- [Local Network Discovery](/docs/developers/p2p/local-network-discovery) via mDNS
- [Relay](/docs/developers/p2p/relay) via mDNS

## Overview of methods

From a technical perspective all of these methods operate very differently so it's important to understand the differences between them when making changes to the P2P system.

The relay and manual entry method both require the P2P system to be given an upfront list of peers to connect to, whereas the mDNS system is able to discover them itself. For the relay these peers comes from the instances table in the database and for manual entry these peers comes from the node configuration file.

A quirk manual entry is that when we attempt a connection we don't know the remote nodes identity or metadata prior to connecting. We instead establish a full connection to ask for remote nodes information (`RemoteIdentity` and metadata) after which we treat it as discovered.

This table summarises the differences between the methods:

|                                                                      | mDNS | Relay | Manual |
| -------------------------------------------------------------------- | ---- | ----- | ------ |
| Requires upfront knowledge of existence of peer                      | No   | Yes   | Yes    |
| Knows connection info (metadata, RemoteIdentity) ahead of connection | Yes  | Yes   | No     |

## Manually provided peers

The user can manually provide a set of [`SocketAddr`](https://doc.rust-lang.org/std/net/enum.SocketAddr.html)'s or [FQDN](https://en.wikipedia.org/wiki/Fully_qualified_domain_name)'s and the P2P system will attempt to connect to them. If a domain is provided the P2P system will resolve it to an IP address and then attempt to connect to that address.

This feature primarily exists for usage with Docker as mDNS discovery does not work correctly, however it could be useful for working around difficult network setups. It's important to note that you _must_ use [port forwarding](https://en.wikipedia.org/wiki/Port_forwarding) and set a static port for the node when using this feature.

When you add a manual peer it will _not_ show up in the nodes list until the P2P system is able to establish a connection. This is because without having established a connection the system is unable to determine the remote nodes identity or metadata which is required for it to be considered discovered.
